package com.dlc.felear.xiaoensale.customView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.GridView;

import com.dlc.felear.xiaoensale.adapter.PageIndicatorAdapter;


/**
 *自定义圆点导航指示器
 */
public class RoundNavigationIndicator extends GridView {
    private int pageSize=3;
    private int index=0;
    private PageIndicatorAdapter pageIndicatorAdapter;
    public RoundNavigationIndicator(Context context) {
        super(context);
        initView(context);
    }

    public RoundNavigationIndicator(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public RoundNavigationIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }
    private void initView(Context context){
        pageIndicatorAdapter=new PageIndicatorAdapter(context);
        setNumColumns(5);
        setColumnWidth(0);
        setGravity(Gravity.END);
        setHorizontalSpacing(10);
        setAdapter(pageIndicatorAdapter);
    }
    public void setCurrentPage(int pageSize,int index){
        if(pageSize<=1){
            pageSize=0;
        }
        pageIndicatorAdapter.setItems(pageSize,index);
    }
}
